﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rapid
{
    public class TestCommon
    {
        static RapidDataDataContext db = new RapidDataDataContext();
        public ETestCommon testType;
        public EObservationCommon observation;

        public TestCommon(ETestCommon testType, EObservationCommon observation)
        {
            this.testType = testType;
            this.observation = observation;
        }

        public void ChangeObservationWithRules()
        {
            switch (this.observation)
            {
                case EObservationCommon.Normal:
                    this.observation = EObservationCommon.Abnormal;
                    break;
                default://AbNormal
                    this.observation = EObservationCommon.Normal;
                    break;
            }
        }

        public string GetInterPretation()
        {
            return ResultInterpretation.GetCommonInterpretation(this.observation);
        }

        public string GetResultText()
        {
            var tempObservation = db.Observations.Single(ob => ob.TypeDrug == 3 && ob.ObservationType == this.observation.ToString());
            return (tempObservation.Flag == 0) ? tempObservation.Interpretation : "";
        }

        public string GetResultFlag()
        {
            var tempObservation = db.Observations.Single(ob => ob.TypeDrug == 3 && ob.ObservationType == this.observation.ToString());
            return (tempObservation.Flag == 1) ? tempObservation.Interpretation : "";
        }

        public string GetObservstionName()
        {
            return this.observation.ToString();
        }

        public string GetTestName()
        {
            return this.testType.ToString();
        }

        public string GetDisplay()
        {
            return GetTestName() + ": " + GetObservstionName();
        }
    }
}
